package com.example.service.impl;


import com.example.bean.Address;
import com.example.bean.ResultVo;
import com.example.mapper.AddressMapper;
import com.example.service.AddressService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service(value = "AddressService")
public class AddressServiceImpl implements AddressService {
    @Autowired
    AddressMapper addressMapper;
//查出所有地址

    @Override
    public List<Address> findAll(int uId) {
        return addressMapper.findAll(uId);
    }

    //修改地址
    @Override
    public ResultVo modifUpdateAddress(int aId, String rName, String rPhone, String rAddress) {
        return new ResultVo(addressMapper.updateAddress(aId, rName, rPhone, rAddress));
    }
//删除地址
    @Override
    public Boolean deleteAddress1(int aId) {
        return addressMapper.deleteAddress(aId);
    }
//增加地址
    @Override
    public Boolean addAddress1(Address address) {
        int i = addressMapper.AddAddress(address.getUId(), address.getRName(), address.getRPhone(), address.getRAddress());
        if (i!=0){
            return true;
        }
        return false;
    }
//查询默认地址
    @Override
    public Address findDefaultAddress(int uid) {
        return addressMapper.findDefaultAddress(uid);
    }

}
